package com.hh.vrserver.web.config;

import com.hh.vrserver.web.vo.WebResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * controller 异常处理
 *
 * @author yeweijun
 * @version 1.0
 * @date 2022/7/11 17:31
 */
@Slf4j
@RestControllerAdvice
public class ExceptionHandlerConfig {

    @ExceptionHandler({
            IllegalArgumentException.class,
            IllegalStateException.class,
            Exception.class
    })
    public WebResult<Void> handlerException(Exception ex) {
        log.error("系统处理异常", ex);
        return WebResult.fail(ex.getMessage());
    }

}
